<template>
    <div>

<h2>登录</h2>
<table class="table">
<tbody>
    <tr>
        <td>账号</td>
        <td>
            <input type="text" v-model="model.UserName">
        </td>
    </tr>

    <tr>
        <td>密码</td>
        <td>
            <input type="password" v-model="model.UserPwd">
        </td>
    </tr>


    <tr>
        <td></td>
        <td>
            <input type="button" value="登录" class="btn btn-success" @click="ok">
        </td>
    </tr>
</tbody>
</table>

    </div>
</template>

<script setup lang="ts">

import { ref,reactive } from 'vue';
import axios from 'axios';
import { useRoute,useRouter } from 'vue-router';
const route=useRoute();
const router=useRouter();

let model=reactive({

"UserName": '',
 "UserPwd": '',
})


const ok=()=>{
axios({
url:'https://localhost:7190/api/House/Login',
method:'post',
data:model,
})

.then((res)=>{
console.log(res);
if(res.data==-1){
    alert('用户名不存在');
    return;
}
else if(res.data==-2){

    alert('密码错误');
    return;
}
else{
    alert('登录成功');
    router.push('/houseList')
    return;
}


})

.catch((ree)=>{
console.log(ree);
})














}
</script>

<style scoped>

</style>